<?php
/**
 * Created by PhpStorm.
 * User: DINGHAO
 * Date: 2018/11/8
 * Time: 8:24
 */
namespace Admin\Controller;

class OrderController extends CommonController{
    //订单列表
    public function listOrder(){
        $model=M('Order');
        $count=$model->count();
        //实例化分页类
        $page=new \Think\Page($count,10);
        $page->setConfig('prev','上一页');
        $page->setConfig('next','下一页');
        $show=$page->show();
        $data=$model->limit($page->firstRow,$page->listRows)->select();

        if(empty($data)){
            $this->error('还没有订单呢!');exit;
        }
        $this->assign('data',$data);
        $this->assign('show',$show);
        $this->display();
    }
    //删除订单
    public function del(){
        $id=I('id');
        $result=M('Order')->delete($id);
        if($result){
            $this->success('订单删除成功！');
        }else{
            $this->error('订单删除失败！');
        }
    }
    public function show(){
        $id=I('id');
        $data=M('Order')->find($id);
        $this->assign('data',$data);
        $this->display();
    }

}